use utf8_decoder::utf8_decoder::{decode_utf8, UTF8_ACCEPT};

#[test]
fn test_decode_chinese() {
    let s = "成为更健康、更长久的世界一流企业";
    let mut res = [0u32; 64];
    let mut codepoint = 0u32;
    let mut count = 0usize;
    let mut state = 0u32;

    for byte in s.bytes() {
        if decode_utf8(&mut state, &mut codepoint, byte) == UTF8_ACCEPT as u32 {
            res[count] = codepoint;
            count += 1;
        }
    }

    assert_eq!(state, UTF8_ACCEPT as u32);
    assert_eq!(count, 16);
    assert_eq!(res[1], 0x4e3a);
    assert_eq!(res[2], 0x66f4);
    assert_eq!(res[4], 0x5eb7);
    assert_eq!(res[8], 0x4e45);
}